﻿
@using Kooboo.CMS.Content.Models;
@using Kooboo.CMS.Content.Query;
@{ var schema = (Kooboo.CMS.Content.Models.Schema)ViewData["Schema"];
    var allowedEdit = (bool)ViewData["AllowedEdit"];
    var allowedView = (bool)ViewData["AllowedView"];
    var parentUUID = ViewContext.RequestContext.AllRouteValues()["parentUUID"];
    var parentFolder=ViewContext.RequestContext.AllRouteValues()["Folder"];
}
@using(Html.BeginForm(ViewContext.RequestContext.AllRouteValues()["action"].ToString()
    , ViewContext.RequestContext.AllRouteValues()["controller"].ToString()
    , ViewContext.RequestContext.AllRouteValues()
    , FormMethod.Post
    , new RouteValueDictionary(new { enctype = "application/x-www-form-urlencoded" })))
{
    <div class="common-form">
    <fieldset>
    <table><tr>
            <td>
            <label for="Name">Name</label>
            </td>
            <td>
            <input id="Name" name="Name" type="text" value="@(Model.Name ?? "")" />
            @Html.ValidationMessageForColumn(((ISchema)ViewData["Schema"])["Name"], null)
            </td>          
            </tr><tr>
            <td>
            <label for="EnglishName">EnglishName</label>
            </td>
            <td>
            <input id="EnglishName" name="EnglishName" type="text" value="@(Model.EnglishName ?? "")" />
            @Html.ValidationMessageForColumn(((ISchema)ViewData["Schema"])["EnglishName"], null)
            </td>          
            </tr><tr>
            <td>
            <label for="MealTime">MealTime</label>
            </td>
            <td>
            @{ var checkBoxListDefaultValue_MealTime = @"-1".Split(new []{','},StringSplitOptions.RemoveEmptyEntries);
                        var values_MealTime = new string[0];
                        if(!string.IsNullOrEmpty(Model.MealTime))
                        {
                            values_MealTime=Model.MealTime.Split(new []{','},StringSplitOptions.RemoveEmptyEntries);
                        }
                        }
<input id="MealTime_0" name="MealTime" type="checkbox" value="@(@"-1")"  @((Model.MealTime == null && checkBoxListDefaultValue_MealTime.Contains(@"-1",StringComparer.OrdinalIgnoreCase))  || (Model.MealTime != null && values_MealTime.Contains(@"-1",StringComparer.OrdinalIgnoreCase)) ? "checked" : "")/><label for="MealTime_0">All</label>
<input id="MealTime_1" name="MealTime" type="checkbox" value="@(@"1")"  @((Model.MealTime == null && checkBoxListDefaultValue_MealTime.Contains(@"1",StringComparer.OrdinalIgnoreCase))  || (Model.MealTime != null && values_MealTime.Contains(@"1",StringComparer.OrdinalIgnoreCase)) ? "checked" : "")/><label for="MealTime_1">Mon</label>
<input id="MealTime_2" name="MealTime" type="checkbox" value="@(@"2")"  @((Model.MealTime == null && checkBoxListDefaultValue_MealTime.Contains(@"2",StringComparer.OrdinalIgnoreCase))  || (Model.MealTime != null && values_MealTime.Contains(@"2",StringComparer.OrdinalIgnoreCase)) ? "checked" : "")/><label for="MealTime_2">Tue</label>
<input id="MealTime_3" name="MealTime" type="checkbox" value="@(@"3")"  @((Model.MealTime == null && checkBoxListDefaultValue_MealTime.Contains(@"3",StringComparer.OrdinalIgnoreCase))  || (Model.MealTime != null && values_MealTime.Contains(@"3",StringComparer.OrdinalIgnoreCase)) ? "checked" : "")/><label for="MealTime_3">Wed</label>
<input id="MealTime_4" name="MealTime" type="checkbox" value="@(@"4")"  @((Model.MealTime == null && checkBoxListDefaultValue_MealTime.Contains(@"4",StringComparer.OrdinalIgnoreCase))  || (Model.MealTime != null && values_MealTime.Contains(@"4",StringComparer.OrdinalIgnoreCase)) ? "checked" : "")/><label for="MealTime_4">Thur</label>
<input id="MealTime_5" name="MealTime" type="checkbox" value="@(@"5")"  @((Model.MealTime == null && checkBoxListDefaultValue_MealTime.Contains(@"5",StringComparer.OrdinalIgnoreCase))  || (Model.MealTime != null && values_MealTime.Contains(@"5",StringComparer.OrdinalIgnoreCase)) ? "checked" : "")/><label for="MealTime_5">Fri</label>
<input id="MealTime_6" name="MealTime" type="checkbox" value="@(@"6")"  @((Model.MealTime == null && checkBoxListDefaultValue_MealTime.Contains(@"6",StringComparer.OrdinalIgnoreCase))  || (Model.MealTime != null && values_MealTime.Contains(@"6",StringComparer.OrdinalIgnoreCase)) ? "checked" : "")/><label for="MealTime_6">Sat</label>
<input id="MealTime_7" name="MealTime" type="checkbox" value="@(@"0")"  @((Model.MealTime == null && checkBoxListDefaultValue_MealTime.Contains(@"0",StringComparer.OrdinalIgnoreCase))  || (Model.MealTime != null && values_MealTime.Contains(@"0",StringComparer.OrdinalIgnoreCase)) ? "checked" : "")/><label for="MealTime_7">Sun</label>
            @Html.ValidationMessageForColumn(((ISchema)ViewData["Schema"])["MealTime"], null)
            </td>          
            </tr><tr>
            <td>
            <label for="Price">Price</label>
            </td>
            <td>
            <input id="Price" name="Price" type="Float" value="@(Model.Price ?? "")"  data-val-number="The field Price must be a number." data-val="true" value-type="float"/>
            @Html.ValidationMessageForColumn(((ISchema)ViewData["Schema"])["Price"], null)
            </td>          
            </tr>
            @if (allowedEdit) {
                <tr>
            <td>
            <label for="Published">Published</label>
            </td>
            <td>
            <input name="Published" type="checkbox" @(Convert.ToBoolean(Model.Published)?"checked":"") value="true"/>
                                    <input type="hidden" value="false" name="Published"/>
            @Html.ValidationMessageForColumn(((ISchema)ViewData["Schema"])["Published"], null)
            </td>          
            </tr>
            }
    @Html.Action("Categories", ViewContext.RequestContext.AllRouteValues())
    @if (schema.IsTreeStyle && parentUUID!=null)
    {
        <input type="hidden" name="ParentUUID" value="@parentUUID"/> 
        <input type="hidden" name="ParentFolder" value="@parentFolder" />
    }
    </table>
    </fieldset>
    <p class="buttons"><button type="submit">@("Save".Localize())</button> <a href="javascript:;" class="dialog-close button">@("Close".Localize())</a> </p>
    </div>
}